package com.test.nnooolwdeaer.view_wooden.info_input_wooden;

import static android.view.View.GONE;
import static android.view.View.VISIBLE;

import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.test.nnooolwdeaer.R;
import com.test.nnooolwdeaer.bean_wooden.process_wooden.ProcessData_wooden;
import com.test.nnooolwdeaer.view_wooden.base_wooden.BaseInfoInputViewManager_wooden;

public class GenderSelectViewManager_wooden extends BaseInfoInputViewManager_wooden {

    private TextView titleTv_wooden;
    private TextView maleTv_wooden, femaleTv_wooden;

    private String selectGender = "";

    private final String genderMale;
    private final String genderFemale;

    public GenderSelectViewManager_wooden(View view, ProcessData_wooden data){
        super(view,data,"");

        genderMale = mView_wooden.getResources().getString(R.string.view_gender_select_male);
        genderFemale = mView_wooden.getResources().getString(R.string.view_gender_select_female);

        titleTv_wooden = mView_wooden.findViewById(R.id.view_gender_select_tv_title);
        maleTv_wooden = mView_wooden.findViewById(R.id.view_gender_select_tv_male);
        femaleTv_wooden = mView_wooden.findViewById(R.id.view_gender_select_tv_female);

        maleTv_wooden.setOnClickListener(v -> setGender_wooden(genderMale));
        femaleTv_wooden.setOnClickListener(v -> setGender_wooden(genderFemale));

        setTitle_wooden(mData_wooden.getTitle_wooden());

    }

    @Override
    protected void init_wooden(){}

    @Override
    public boolean checkInput_wooden() {
        return !TextUtils.isEmpty(getInput_wooden());
    }

    @Override
    public String getInput_wooden() {
        return selectGender;
    }

    public void setGender_wooden(String gender){
        selectGender = gender;
        if (genderMale.equalsIgnoreCase(gender)){
            maleTv_wooden.setBackgroundResource(R.drawable.ic_service_feedback_type_true);
            maleTv_wooden.setTextColor(Color.WHITE);
            femaleTv_wooden.setBackgroundResource(R.drawable.bg_gender);
            femaleTv_wooden.setTextColor(Color.parseColor("#FF919191"));
        }else if (genderFemale.equalsIgnoreCase(gender)){
            femaleTv_wooden.setBackgroundResource(R.drawable.ic_service_feedback_type_true);
            femaleTv_wooden.setTextColor(Color.WHITE);
            maleTv_wooden.setBackgroundResource(R.drawable.bg_gender);
            maleTv_wooden.setTextColor(Color.parseColor("#FF919191"));
        }
    }

    public void setTitle_wooden(String title){
        if (TextUtils.isEmpty(title)) titleTv_wooden.setVisibility(GONE);
        else {
            titleTv_wooden.setVisibility(VISIBLE);
            titleTv_wooden.setText(title);
        }
    }

}
